<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./js/vue.js"></script>
    <style>
        #app{
            border: 2px solid black;
            padding: 10px;
            margin-bottom: 400px;
        }
        .child{
            margin: 20px;
            padding: 10px;
            background-color: #cccccc;
        }
    </style>
</head>
<body>
    <div id="app">
        <h3>父组件范围</h3>
        <p>msg:{{msg}}</p>
        <input type="text" v-model="msg">
        <hr>
        <p>skills:{{ skills }}</p>
        <div>
            html:<input type="checkbox" value="html" v-model="skills">
            javaScript:<input type="checkbox" value="javaScript" v-model="skills">
            Vue:<input type="checkbox" value="Vue" v-model="skills">
        </div>
        <hr>
        <child-one :msg.sync="msg" :skills.sync="skills"></child-one>
    </div>

    <template id="ChildOne">
        <div class="child">
            <h3>子组件</h3>
            <p>msg:{{ msg }}</p>
            <input type="text" v-model="returnMsg">
            <hr>
            <p>skills:{{skills}}</p>
            <div>
                html:<input type="checkbox" value="html" v-model="returnSkills">
                javaScript:<input type="checkbox" value="javaScript" v-model="returnSkills">
                Vue:<input type="checkbox" value="Vue" v-model="returnSkills">
            </div>
        </div>
    </template>
</body>
<script>
    Vue.component("ChildOne",{
        template:"#ChildOne",
        props:["msg","skills"],
        computed:{
            returnMsg:{
                get(){
                    return this.msg
                },
                set(nv){
                    this.$emit("update:msg",nv);
                }
            },
            returnSkills:{
                get(){
                    return this.skills
                },
                set(nv){
                    this.$emit("update:skills",nv);
                }
            }
        },
        mounted() {
            console.log(this)
        },
    })
    new Vue({
        el:"#app",
        data:{
            msg:"测试数据",
            skills:[]
        }
    })
</script>
</html>